package ru.papergames.utils.helpers
{
	import flash.events.KeyboardEvent;
	
	public final class KeyboardHelper
	{
		public static const KEY_PREFIX:String = 'k_';
	
		private static var KEYS_STATE:Object = {};
		
		public static function handleKeyBoardEvent(evt:KeyboardEvent):void {
			switch(evt.type) {
				case KeyboardEvent.KEY_DOWN:
					KEYS_STATE[KEY_PREFIX + evt.keyCode] = true;
				break;
				
				case KeyboardEvent.KEY_UP:
					KEYS_STATE[KEY_PREFIX + evt.keyCode] = false;
				break;
			}
		}
		
		public static function checkState(code:uint):Boolean {
			return KEYS_STATE[KEY_PREFIX + code]
		}
	}
}